package com.corpgovernment.supplier.controller;


import com.corpgovernment.common.base.BaseUserInfo;
import com.corpgovernment.common.base.JSONResult;
import com.corpgovernment.supplier.service.IMbSupplierCompanySericeImpl;
import com.corpgovernment.supplier.vo.QuerySupplementListReqVo;
import com.corpgovernment.supplier.vo.QuerySupplementListRspVo;
import com.ctrip.corp.obt.generic.utils.JsonUtils;
import com.ctrip.corp.obt.generic.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/supplement")
public class SupplierSupplementController {
    @Autowired
    private IMbSupplierCompanySericeImpl mbSupplierCompanyService;

    /**
     * 供应商补录用户列表
     *
     * @param reqVo
     * @return
     */
    @PostMapping(value = "list")
    public JSONResult list(@RequestBody QuerySupplementListReqVo reqVo, BaseUserInfo baseUserInfo) {
        if (reqVo.getSupplierCode() == null) {
            reqVo.setSupplierCode(baseUserInfo.getSupplierCode());
        }
        if (StringUtils.isEmpty(reqVo.getSupplierCode())) {
            JSONResult.errorMsg("供应商编码不能为空");
        }
        log.info("获取到的用户信息:{}", JsonUtils.toJsonString(baseUserInfo));
        QuerySupplementListRspVo querySupplementListRspVo = mbSupplierCompanyService.getSupplementList(reqVo);
        return JSONResult.success(querySupplementListRspVo);
    }
}
